<?
	$title="Sales Of Evidence Group View";
	$mid=1;
	require("required/dbconnect.php");
	require_once("required/function.php");
	checkAccess("allow_soe_management",1);
	require("required/header.php");
?>
<script src="required/js/jquery-1.4.2.js"></script>
<script src="required/js/common_javascript.js"></script>
<?
		
	if(!empty($_GET['action']))
	{
		
		switch($_GET['action'])
		{
			case 1:
				$msg="<div class='dw_success'>Data inserted</div>";
				break;
			case 2:
				$msg="<div class='dw_success'>Data Deleted</div>";
				break;
			case 3:
				$msg="<div class='dw_success'>Data Updated</div>";
				break;
			case 4:
				$msg="<div class='dw_failed'>User already exist, insert failed!</div>";
				break;			
			default:
				$msg="";
				break;
		}
		echo "<script>displayMsg('divMsg')</script>";
	}else{
		$msg="";
	}
	
	if(empty($_GET['page']))
	{
		$page="1";
	}
	else
	{
		$page=$_GET['page'];
	}
	
	$totalperpage=30;

	$from=($page-1)*$totalperpage;	
	
	$get_data=mysql_query("select * from tbl_soe_group order by group_name asc limit $from,$totalperpage")or die(mysql_error());
	$get_total=mysql_query("select count(*) as result from tbl_soe_group")or die(mysql_error());
	
	
	
	
	$count=mysql_result($get_total,0,"result");
	
	
?>

<table width="100%" cellpadding="0" cellspacing="0" height="100%">
    <? require("required/menu_soe.php"); ?>
    <td valign="top" align="left">
       <table width="95%" align="center">
       		<tr>
            	<td class="title"><?= $title ?></td>
            </tr>
             <tr>
            	<td><div id="divMsg"><?= $msg ?></div></td>
            </tr>
            <tr>
            	<td colspan="2">
            <?
					if($count>0)
					{
				?>
                    <?= getPaging($totalperpage,$count,$page,"soe_group_view_all.php?noparam=1") ?>
                <?
					}
				?>
                </td>
            </tr>
            <tr>
            	<td>
                	<table width="100%" class="solidborder" >
         			 <Tr class="table_header">
                       <td width="30">No.</td>
                       <td width="392">Group Name</td>
                       <td width="356">Total Records</td>
                       <td width="413">Created Date</td>
                       <Td width="277"> Created By</Td>
                       <Td width="255">Action</Td>
                     </Tr>
                            <?
								if(mysql_num_rows($get_data)==0)
								{		
							?>
                            <tr>
                            	<Td colspan="8" align="center"> No record found</Td>
                            </tr>
                            <? 
								}
								else
								{ 
									$no=$from+1;
									
									
									
									while($a=mysql_fetch_array($get_data,MYSQL_ASSOC))
									{
										if($no%2==0)
										{
											$class1="table_item_even";
											$class2="table_item_odd";
										}
										else
										{
											$class1="table_item_odd";
											$class2="table_item_even";
										}
										
										$get_total=mysql_query("select count(*) as result from tbl_soe where group_id=".$a['id']);
										
										
										
							?>
                            <tr height="20" valign="top" class="<?= $class1 ?>" align="center" onmouseover="this.className='table_item_mouseover';this.style.cursor='pointer'" 
                            onmouseout="this.className='<?= $class1 ?>'" onclick="window.open('soe_view_all.php?group_id=<?= $a['id'] ?>','_self')">
                            	<td><?= $no ?></td>                               	
                                <td align="left"><?= $a['group_name'] ?></td>
                                <td  align="center"><?= mysql_result($get_total,0,"result") ?></td>
                                <td align="center"><?= $a['created_datetime'] ?></td>                           
                                <td align="center"><?= getDataById("adm_user","user_name","id",$a['created_by']) ?></td> 
                                 <td align="center">
                                 	<?
										if(checkAccess("allow_soe_edit",0)){
									?>
                                	<a href="soe_group_edit.php?id=<?= $a['id'] ?>"><img src="themes/<?= $set_theme ?>/images/icons/edit.gif" border="0"></a>
                                    <? } ?>
                                    
                                    <?
										if(checkAccess("allow_soe_delete",0)){
									?>
                                    <a href="soe_group_delete.php?id=<?= $a['id'] ?>"><img src="themes/<?= $set_theme ?>/images/icons/delete.gif" border="0"></a>
                                    <? } ?>
                                </td>   
                            </tr>
                            <? 
									$no++;
									}
								}
							
							 ?>
                        
                        
                    </table>
                
              </td>
            </tr>
       </table>
       
    </td>
</table>					
<?
	require("required/footer.php");
?>               
        